package com.ayq.activiti.model.config;

import com.ayq.activiti.common.util.TwitterSnowFlakeIdGenerator;
import org.activiti.engine.impl.cfg.IdGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class ActivitiIdGenerator implements IdGenerator {

    protected static final Logger LOGGER = LoggerFactory.getLogger(ActivitiIdGenerator.class);
    private TwitterSnowFlakeIdGenerator twitterSnowFlakeIdGenerator = new TwitterSnowFlakeIdGenerator(0, 0);

    /**
     * 封装JDK自带的UUID, 通过Random数字生成, 中间无-分割.
     */
    public String uuid() {
        LOGGER.info("SnowflakeIdGenerator [{}]", twitterSnowFlakeIdGenerator);
        return String.valueOf(twitterSnowFlakeIdGenerator.nextId());
    }

    /**
     * Activiti ID 生成
     */
    @Override
    public String getNextId() {
        return uuid();
    }

}
